home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / gas_251.zip / bin_251 / bfd / pc532-mach.c < prev    next >
C/C++ Source or Header  |  1994-08-08  |  4KB  |  131 lines

  1. /* BFD back-end for Mach3/532 a.out-ish binaries.
  2.    Copyright (C) 1990, 1991, 1992, 1994 Free Software Foundation, Inc.
  3.  
  4. This file is part of BFD, the Binary File Descriptor library.
  5.  
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2 of the License, or
  9. (at your option) any later version.
  10.  
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with this program; if not, write to the Free Software
  18. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  19.  
  20. /* Written by Ian Dall
  21.  *            19-Apr-94
  22.  *
  23.  * Formerly part of aout-pc532-mach.c. Split out to allow more
  24.  * flexibility with multiple formats.
  25.  *
  26.  */
  27. /* This architecture has N_TXTOFF and N_TXTADDR defined as if
  28.  * N_HEADER_IN_TEXT, but the a_text entry (text size) does not include the
  29.  * space for the header. So we have N_HEADER_IN_TEXT defined to
  30.  * 1 and specially define our own N_TXTSIZE
  31.  */
  32.  
  33. #define N_HEADER_IN_TEXT(x) 1
  34. #define N_TXTSIZE(x) ((x).a_text)
  35.  
  36.  
  37. #define TEXT_START_ADDR 0x10000       /* from old ld */
  38. #define PAGE_SIZE 0x1000       /* from old ld,  032 & 532 are really 512/4k */
  39.  
  40. /* Use a_entry of 0 to distinguish object files from OMAGIC executables */
  41. #define N_TXTADDR(x) \
  42.   (N_MAGIC(x) == OMAGIC ? \
  43.    ((x).a_entry < TEXT_START_ADDR? 0: TEXT_START_ADDR): \
  44.    (N_MAGIC(x) == NMAGIC? TEXT_START_ADDR: \
  45.     TEXT_START_ADDR + EXEC_BYTES_SIZE))
  46.  
  47. #define    SEGMENT_SIZE    PAGE_SIZE
  48.  
  49. #define N_SHARED_LIB(x) 0
  50. #define SEGMENT_SIZE PAGE_SIZE
  51. #define DEFAULT_ARCH bfd_arch_ns32k
  52.   
  53. #define MY(OP) CAT(pc532machaout_,OP)
  54.  
  55. #define TARGETNAME "a.out-pc532-mach"
  56.  
  57. #include "bfd.h"
  58. #include "sysdep.h"
  59. #include "libaout.h"
  60. #include "libbfd.h"
  61. #include "aout/aout64.h"
  62.  
  63. /* We can`t use the MYNS macro here for cpp reasons too subtle for me -- IWD */
  64.  
  65. #define MY_bfd_reloc_type_lookup ns32kaout_bfd_reloc_type_lookup
  66.  
  67. /* libaout doesn't use NAME for these ... */
  68.  
  69. #define MY_get_section_contents aout_32_get_section_contents
  70.  
  71. /* Forward declaration. Defined in aout-target.h */
  72.  
  73. static boolean MY(set_sizes)();
  74.      
  75. static CONST struct aout_backend_data MY(backend_data) =
  76. {
  77.   0,                /* zmagic contiguous */
  78.   1,                /* text incl header */
  79.   0,
  80.   0,                /* text vma? */
  81.   MY(set_sizes),
  82.   1,                /* exec header is not counted */
  83. };
  84.      
  85. #define MY_backend_data &MY(backend_data)
  86.      
  87. #define MYNSX(OP) CAT(ns32kaout_,OP)
  88. CONST struct reloc_howto_struct *
  89. MYNSX(bfd_reloc_type_lookup)
  90.   PARAMS((bfd *abfd AND
  91.       bfd_reloc_code_real_type code));
  92.  
  93. boolean
  94. MYNSX(write_object_contents)
  95.   PARAMS((bfd *abfd));
  96.  
  97. static boolean
  98. MY(write_object_contents) (abfd)
  99. bfd *abfd;
  100. {
  101.   struct external_exec exec_bytes;
  102.   struct internal_exec *execp = exec_hdr (abfd);
  103.   
  104. #if CHOOSE_RELOC_SIZE
  105.   CHOOSE_RELOC_SIZE(abfd);
  106. #else
  107.   obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
  108. #endif
  109.   
  110.   BFD_ASSERT (bfd_get_arch (abfd) == bfd_arch_ns32k);
  111.   switch (bfd_get_mach (abfd))
  112.     {
  113.     case 32032:
  114.       N_SET_MACHTYPE (*execp, M_NS32032);
  115.       break;
  116.     case 32532:
  117.     default:
  118.       N_SET_MACHTYPE (*execp, M_NS32532);
  119.       break;
  120.     }
  121.   N_SET_FLAGS (*execp, aout_backend_info (abfd)->exec_hdr_flags);
  122.   
  123.   WRITE_HEADERS(abfd, execp);
  124.   
  125.   return true;
  126. }
  127.  
  128. #define MY_write_object_contents MY(write_object_contents)
  129.  
  130. #include "aout-target.h"
  131.